<?php

namespace app\admin\validate;

use think\Validate;

class Admin extends Validate
{
    //验证规则
    protected $rule = [
        'username|用户名' => 'require|token',
        'nickname|昵称' => 'require|chsAlpha',
        'password|密码' => 'require|number|length:4,8',
        'email|邮箱' => 'require|email',
        'code' => 'require|captcha' //captcha 框架自动验证
    ];

    //验证提示
    protected $message = [
        'username.require' => '用户名不能为空，不知道吗？',
        'username.token' => '请勿重复提交数据！！！',
        'nickname.require' => '昵称不能为空，不知道吗？',
        'nickname.chsAlpha' => '昵称1sdsds只能为汉字和字11asdasd1母',
        'password.require' => '密码不能为空，不知道吗？',
        'password.number' => '密码只能为数字',
        'password.length' => '密码长度在4到8之间',
        'code.require' => '验证码不能为空1111',
    ];

    //验证场景
    protected $scene = [
        'login' => ['username','password','code'],
    ];
}